import request from "@/utils/request";
import Qs from "qs";

// 查询新闻列表
export function getNewsList(params) {
  console.log(params);
  return request({
    url: "/news/detail/list",
    params,
    paramsSerializer: (params) => {
      return Qs.stringify(params, { indices: false });
    },
  });
}

// 改变新闻状态
export function changeNewsStatus(params) {
  return request({
    url: "/news/detail/changeStatus",
    method: "put",
    params,
  });
}

// 发布新闻
export function releaseNews(data) {
  return request({
    url: "/news/detail/create",
    method: "post",
    data,
  });
}

// 删除新闻
export function deleteNews(params) {
  return request({
    url: "/news/detail/deleteByIds",
    method: "delete",
    params,
    paramsSerializer: (params) => {
      return Qs.stringify(params, { indices: false });
    },
  });
}

// 修改新闻
export function alterNews(data) {
  return request({
    url: "/news/detail/change",
    method: "put",
    data,
  });
}

// 根据Id查询新闻详情
export function queryNewsDetailById(params) {
  return request({
    url: "/news/detail/queryById",
    params,
  });
}

// 查询新闻类型
export function getNewsType(params) {
  return request({
    url: "/news/category/list",
    params,
  });
}

// 获取所有新闻类型(无分页，无条件)
export function getAllNewsType() {
  return request({
    url: "/news/category/queryAll",
  });
}

// 创建新闻类型
export function createNewsType(data) {
  return request({
    url: "/news/category/create",
    method: "post",
    data,
  });
}

// 删除新闻类型
export function deleteNewsType(params) {
  return request({
    url: "/news/category/deleteByIds",
    method: "delete",
    params,
  });
}
